home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BBS in a Box 7
/
BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso
/
Files
/
Bus
/
A
/
Acius08⁄92.cpt
/
Acius08_92
/
Encoding_Decipheringƒ
/
Sources
/
DecryptPicture.a
next >
Wrap
Text File
|
1992-08-17
|
3KB
|
109 lines
;
; Deciphering pictures external routine for 4D
; written by François Marchal, © ACI 1992
;
; Parameters :
; -> Picture to encode
; -> Longint key word (you need the same key to encode and to decipher the picture)
;
CASE OBJ
INCLUDE 'traps.a'
picsize EQU 104
signature EQU 98
masignature EQU $464D
Cle EQU 100
picend EQU 6
EXPORT DecryptPicture
DecryptPicture PROC
CODE
LINK A6,#$0
MOVEM.L D4-D7/A4,-(A7) ; save the used registers
MOVEA.L 12(A6),A4
MOVE.L (A4),A4 ; A4 : Handle on the picture to encode
BEQ Fini ; if the Handle passed is Nil, don't do anything
MOVE.L (A4),A0
MOVE.W signature(A0),D0
CMPI.W #masignature,D0 ; verify if the handle hasn't been signed
BNE.S fini ; if the picture has already been encoded, don't do anything
MOVE.L 8(A6),A0 ; dereferencing (parameter passed in var)
MOVE.L (A0),D4 ; of the deciphering key
MOVE.L (A4),A0 ; dereferencing the Handle
CMP.L Cle(A0),D4 ; compare the deciphering key passed with the encoding key
BNE.S fini ; don't do anything if the keys are not identical
MOVE.L A4,A0
_GetHandleSize
MOVE.L D0,D7 ; memorize the size of the new Handle in D7
BEQ.S fini ; if the Handle is empty, stop
SUB.L #picsize+picend,D7 ; D7 = size of the handle minus the header minus the picend
BLE.S fini ; if it's negative, stop
MOVE.L (A4),A0 ; go to the beginning of the data
ADDA.L #picsize,A0 ; plus the header
MOVE.L D7,D0 ; D0 : number of bytes to decipher
MOVE.L D0,D6
ANDI.L #$1F,D6 ; D6 -> the remainder of the whole division of D7 by 32
LSR.L #5,D0 ; divide by 32 of the size of the Handle
BEQ.S GereReste ; allows us to know the number of passes in the loop
SUBQ #1,D0 ; take 1 to D7 for the dbra
Loop:
MOVE.L D4,D5
SUB.L D0,D5
EOR.L D5,(A0)+ ; 1
EOR.L D5,(A0)+ ; 2
EOR.L D5,(A0)+ ; 3
EOR.L D5,(A0)+ ; 4
EOR.L D5,(A0)+ ; 5
EOR.L D5,(A0)+ ; 6
EOR.L D5,(A0)+ ; 7
EOR.L D5,(A0)+ ; 8 x 4 = 32 bytes processed by the loop
DBRA D0,Loop
GereReste: ; take care of the remaining bytes
CMPI.L #0,D6
BLE.S Suite
EOR.B D6,(A0)+
SUBQ #1,D6
BRA.S GereReste
Suite:
MOVEA.L (A4),A1 ; A0 = Source -> Block address + block size - header size
MOVEA.L A1,A0 ; A1 = Dest -> Block address
ADDA.L D7,A0 ; of the data moved toward the bottom of the size of the lock picture
MOVE.L #picsize,D0 ; Length -> la taille primary of the Handle
_BlockMove ; replace the primary header on top of mine
MOVE.L (A4),A0
ADDA.L D7,A0 ; move the 6 bytes from the picend
MOVEA.L A0,A1 ; to the end of the block
ADDA.L #picsize,A1
MOVE.L (A1)+,(A0)+
MOVE.W (A1)+,(A0)
MOVE.L A4,A0 ; Handle in A0
MOVE.L D7,D0 ; new size in D0
ADDQ #picend,D0
_SetHandleSize ; readjust the size of the Handle (delet the header)
Fini:
MOVEM.L (A7)+,D4-D7/A4 ; restoring the registers
UNLK A6
MOVEA.L (A7)+,A0 ; read the return address
ADDQ.L #$8,A7 ; take the parameters off of the stack
JMP (A0) ; and return to the calling point
ENDP
END